<?php

use yii\db\Migration;

/**
 * Class m171124_054654_message_user_group_table
 */
class m171124_054654_message_user_group_table extends Migration
{
    /**
     * @inheritdoc
     */
    public function up()
    {
        $this->createTable('message_user_group', [
            'id' => $this->bigPrimaryKey(),
            'user_id' => $this->integer()->notNull()->comment('用户id/角色下的用户id'),
            'message_user_group_id'=> $this->integer()->notNull()->comment("外键关联站内消息ID"),
            'message_state' => $this->smallInteger()->notNull()->comment('消息状态 0未阅读 1已阅读'),
            'message_group' => $this->smallInteger()->notNull()->comment('消息分类 1待审批提醒 2审批反馈 3关注更新'),
            'message_read_time' => $this->integer()->defaultValue(0)->comment('消息阅读时间'),
            'message_read_IP' => $this->integer()->defaultValue(0)->comment('消息阅读人'),
        ]);
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropTable('instation_message');
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m171124_054654_message_user_group_table cannot be reverted.\n";

        return false;
    }
    */
}
